package modelo;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Index;

@Entity
@Table(name="telefone")
public class Telefone implements Serializable{
	private static final long serialVersionUID = 1L;
	
	private long id;
	private String ddd;
	private String numero;
	private Contato contato;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public long getId() {return id;}
	public void setId(long id) {this.id = id;}
	
	@Column(length=3)
	public String getDdd() {return ddd;}
	public void setDdd(String ddd) {this.ddd = ddd;}
	
	@Column(length=9)
	public String getNumero() {return numero;}
	public void setNumero(String numero) {this.numero = numero;}
	
	@ManyToOne(fetch=FetchType.EAGER)
	@Fetch(FetchMode.JOIN)
	@JoinColumn( name="contato" )
	@ForeignKey(name="contatoKey")
	@Index(name="contatoIndex")
	public Contato getContato() {return contato;}
	public void setContato(Contato contato) {this.contato = contato;}

}
